package cn.butcher21.controller;

import cn.butcher21.dao.DaoWork;
import cn.butcher21.dao.DaoWorkImpl.DaoWorkImpl;
import cn.butcher21.pojo.Project;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

/**
 * butcher create in 2021/04/26/17:56
 * <p>
 * 添加项目
 */
@WebServlet("/addProject")
public class AddProjectServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String name = request.getParameter("name");
        String manager = request.getParameter("manager");
        String userid = (String) request.getSession().getAttribute("userid");
        Project project = new Project();
        project.setName(name);
        project.setManager(manager);
        DaoWork daoWork = new DaoWorkImpl();
        try {
            daoWork.add(project, userid);
        } catch (SQLException e) {
            e.printStackTrace();
            response.setStatus(500);
        }

    }
}
